package com.seari.kafka;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import com.seari.Utils.SpringContainer;
import com.seari.bean.TransferMessage;

public class TransferWorker implements Runnable
{

	private String topic;
	private List data;
	private String type;
	
	@Override
	public void run()
	{
		try
		{
			TransferMessage transferMessage = new TransferMessage();
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			transferMessage.setSource("排班布岗");
			transferMessage.setReceive("任务模块");
			transferMessage.setTime(sdf.format(new Date()));
			transferMessage.setType(type);
			transferMessage.setLine_num("07");
			transferMessage.setLine_name("07号线");
			transferMessage.setStation_num("05");
			transferMessage.setStation_name("顾村公园");
			transferMessage.setSize(data.size());
			transferMessage.setData(data);
			
			System.out.println(transferMessage);
			
			KafkaSender sender = SpringContainer.getBean(KafkaSender.class);
			sender.send(transferMessage, topic);
		} catch (Exception e)
		{
			e.printStackTrace();
		}
	}

	
	public String getTopic()
	{
		return topic;
	}

	public void setTopic(String topic)
	{
		this.topic = topic;
	}

	public List getData()
	{
		return data;
	}

	public void setData(List data)
	{
		this.data = data;
	}

	public String getType()
	{
		return type;
	}

	public void setType(String type)
	{
		this.type = type;
	}
	
	

}
